package gases.as3.librarys.components.skin
{
	import flash.utils.Dictionary;
	
	import gases.as3.librarys.components.skin.data.BaseSkin;
	import gases.as3.librarys.core.Interface.IDispose;

	public class SkinFactory implements IDispose
	{
		public function SkinFactory()
		{
			init();
		}
		
		private function init():void
		{
			_skinClassDict = new Dictionary();
		}
		
		public function addSkinClass(skinType:String, skinClass:Class):void
		{
			_skinClassDict[skinType] = skinClass;
		}
		
		
		public function getSkinClass(skinType:String):BaseSkin
		{
			var cls:Class = _skinClassDict[skinType] as Class;
			if(!cls)
			{
				throw new Error("没有这个类型的皮肤类");
			}
			return new cls();
		}
		
		public function dispose():void
		{
			_skinClassDict = null;
		}
		
		
		private var _skinClassDict:Dictionary;
	}
}